// -----------------------------
// Author: 		Dhaenens Gert 
// Creation: 	12/3/2014 8:10:30 PM				
// -----------------------------

#ifndef _WaterMaterial_h
#define _WaterMaterial_h

#include "ForwardMaterial.h"

class WaterMaterial : public ForwardMaterial
{
public:

	Vector3			m_CameraPosition;

	Color			m_DiffuseColor;
	Float			m_Specular;
	Color			m_SpecularColor;
	Float			m_SpecularPower;
	Color			m_AmbientColor;
	Float			m_AmbientStrength;
	Float			m_Opacity;
	Float			m_WaveSpeed;
	Float			m_Reflection;
	Float			m_MinimumDistance;
	Float			m_MaximumDistance;
	Float			m_MaximumTessFactor;
	Float			m_WaterWidth;
	Float			m_WaterHeight;

	WaterMaterial(Application* lpApp);

	virtual void	Apply(Application* lpApp);
	virtual void	UpdateMatrices(Application* lpApp);
	virtual void	UpdateData(Application* lpApp);

	virtual void	SetDisplacementTexture(RefPtr<ITexture2D> lpDisplacementTexture);
	virtual void	SetReflectionMap(RefPtr<ITexture2D> lpReflectionMap);

	Bool			IsInside(const Vector3& point);

private:

	virtual ~WaterMaterial();

	void				Init(Application* lpApp);

	Vector2				m_UvOffsetR;
	Vector2				m_UvOffsetG;
	Vector2				m_UvOffsetB;
	Vector2				m_UvOffsetA;

	RefPtr<ITexture2D>	m_lpDisplacementMap;
	RefPtr<ITexture2D>	m_lpReflectionMap;

	IVertexShader*		m_lpVertexShader;

	IHullShader*		m_lpHullShader;
	IBuffer*			m_lpTessInfoBuffer;

	IDomainShader*		m_lpDomainShader;

	IGeometryShader*	m_lpGeometryShader;
	IBuffer*			m_lpMatrixBuffer;
	IBuffer*			m_lpUvOffsetBuffer;
	IBuffer*			m_lpGeometryOutput;

	IPixelShader*		m_lpPixelShader;
	IBuffer*			m_lpLightBuffer;
	IBuffer*			m_lpMaterialBuffer;

	IInputLayout*		m_lpInputLayout;
	ISamplerState*		m_lpTextureSampler;

	WaterMaterial(const WaterMaterial& refWaterMaterial);
	WaterMaterial& operator=(const WaterMaterial& refWaterMaterial);
};

#endif